#import Something
#import Character

class BodyLink:
	def __init__(self,part1,hole1,part2,hole2,length):
		self.part1=part1
		self.hole1=hole1
		self.part2=part2
		self.hole2=hole2
		self.length=length
	def process(self):
		E=0.01*(10**9)
		A=0.001#1.2*10**(-4)
		c1=self.get_coord_hole1()
		c2=self.get_coord_hole2()
		dx=c2[0]-c1[0]
		dy=c2[1]-c1[1]
		nlength=(dx**2+dy**2)**0.5
		lp=nlength/self.length-1.0
		N=lp*E*A
		#print "lp",lp
		Fx=N*dx/nlength
		Fy=N*dy/nlength
		self.part1.Fy=self.part1.Fy+Fy
		self.part1.Fx=self.part1.Fx+Fx
		self.part2.Fy=self.part2.Fy-Fy
		self.part2.Fx=self.part2.Fx-Fx
		#self.part1.reposition(self.part1.x+ddx,self.part1.y+ddy)
		#self.part2.reposition(self.part2.x-ddx,self.part2.y-ddy)
	def get_coord_hole1(self):
		dc1=self.part1.cur_holes[self.hole1]
		print dc1
		c1=[dc1[0]+self.part1.x,dc1[0]+self.part1.y+0.5*self.part1.getHeight()]
		return c1
	def get_coord_hole2(self):
		dc2=self.part2.cur_holes[self.hole2]
		print dc2
		c2=[dc2[0]+self.part2.x,dc2[0]+self.part2.y+0.5*self.part2.getHeight()]
		return c2
class RagdollCorpse():
	def __init__(self,links):
		self.links=links
	def process(self):
		for lin in self.links:
			lin.process()